/**************************************
 The code is intended to test functions in linkedl2b.c
 Using only the ReadyQuene as an example. 
***************************************/ 

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "linkedl2.c"

void instructions(void)
{
	printf("Enter your choice:\n"
	    "   1 to insert an element into the list.\n"
	    "   2 to delete an element from the list.\n"
	    "   3 to end.\n");
}



int main(void)
{
	int choice;
	char item[8];
	int cla;
	int pri;

	PCB*  iPCB;


	queue_init();
	instructions();
	printf("?");
	printList(ReadyQuene);

	scanf("%d", &choice);

	while(choice!=3)
	{
		switch(choice)
		{
			case 1:

			printf("Enter the name of PCB: \n");
			scanf("%s", item);
			printf("Enter the class of PCB: \n");
			scanf("%d", &cla);

			printf("Enter the priority of PCB: \n");
			scanf("%d", &pri);

		       /*allocate and create PCB based on the input*/
			iPCB = allo_pcb();
			iPCB = set_pcb(iPCB,item,cla,pri);


			insertpcb(iPCB,2000);
			printList(ReadyQueue);

			break;

			case 2:
			printf("Enter the name of PCB to delete: \n");
			scanf("%s", item);

			if(!isEmpty(ReadyQueue))
			{
				iPCB = delete(ReadyQueue,item);
				printf("%s removed.\n", iPCB->pcb_name);
			}
			printList(ReadyQueue);
			break;

			default:
			printf("Invalid choice.\n");
			break;
		}
		instructions( );
		printf("?");
		scanf("%d", &choice);
	}

	printf("End.\n");
	return 0;

}